The present invention relates to the field of computer systems, and in particular to systems which serve content over a network.
When a user requests infromation from a content server system 10, an example of which is shown in FIG. 1, such as a World Wide Web (web) server, some content 12 will be static in that it is provided to the user regardless of the request by the user, while other content is often dynamically generated by the server executing an embedded source code program 14. The content document to be provided to the user is parsed by a parser 15 to separate static and dynamic content. A verbatim pass-through 16 provides the static content and program code interpreter 18 interprets the embedded source code program to obtain the dynamic content. Alternatively, the program code may be compiled.
In one example, a web server with an application for displaying a stock quote in response to a request from a user dynamically generates a HyperText Markup Language (HTML) page by executing a source code program that looks up the price of the stock and properly formats the information into valid HTML. A box or line for displaying the stock quote may be static content that is the same regardless of which stock quote is entered.
A common technique for generating properly formatted content is to embed HTML formatting directives (tags) directly into the source program code. For example, the following Java code fragment might display a single quote:
out.println(xe2x80x9c less than B greater than xe2x80x9d+getCompanyName( )+xe2x80x9c less than /B greater than xe2x80x9d);
out.println(xe2x80x9c less than I greater than xe2x80x9d+getCompanySymbol( )+xe2x80x9c less than /I greater than xe2x80x9d);
out.println(xe2x80x9c$xe2x80x9d+getFormattedPrice( ));
In the above example, the text contained between the xe2x80x9c less than xe2x80x9d and xe2x80x9c greater than xe2x80x9d characters are HTML tags that produce the desired formatting, while the program code performs the operation of looking up the price and the company name for a stock symbol. When executed, the above program code might yield the following HTML for the fictitious company xe2x80x9cAcme Widgetsxe2x80x9d:
When viewed in an HTML browser, the browser would interpret the tags  less than B greater than  and  less than I greater than  as bolding and italic directives yielding the following rendition:
Acme Widgets, Inc. ACMW $42xe2x85x9
As a further example, it may be desirable to modify the above formatting so that the price is bolded and the company name is not. Such a modification to the formatting would require that a programmer modify the Java source code as follows:
out.println(getCompanyName( ));
out.println(xe2x80x9c less than I greater than xe2x80x9d+getCompanySymbol( )+xe2x80x9c less than /I greater than xe2x80x9d);
out.println(xe2x80x9c less than B greater than $xe2x80x9d+getFormattedPrice( )+xe2x80x9c less than /B greater than xe2x80x9d);
The resulting rendered HTML would appear as follows:
Acme Widgets, Inc. ACMW $42xe2x85x9
This technique of embedding the content formatting directives, such as HTML tags, directly within source program code means that even the simplest change to the desired formatting of the content requires modification, compilation, and testing of the source program code. Furthermore, it is difficult to reuse the source program code in different applications as the generated formatting tags may conflict with the desired format of the new application. Moreover, the generated content is generally embedded within a considerable amount of static content such as page headers, paragraph titles, and layout directives, and such static content must interact cooperatively with the generated content in order for the entire page to be generated correctly. These issues increase the cost of development and maintenance of such applications.
A system and method for interfacing and separating formatted content and program code enables modifications to the formatted content to be made independently of the program code and provides greater reusability of the program code. The system and method have particular application to implementing servers for dynamic web content and applications.
The system and method interface and separate formatted content and program code in connection with a content server system. The system includes a document preprocessor, a compiler, and an execution context manager. The document preprocessor parses and analyzes a formatted content document that contains program invocations and translates the program invocations into a procedure having program code suitable for compilation or intepretation. The preprocessor also encodes designated segments of the content document as subprocedures which are invoked within a context managed by the execution context manager. The execution context manager allows values of parameters to be mapped to named parameters so that the values are available to the invoked procedures and programs. As a result, the content server system provides separation between the formatted content and program code.